#!/bin/sh /etc/rc.common

START=95
STOP=95
NAME=drcom
DESC="ZJUT Dr.com Client"

DAEMON=/usr/bin/drcom
drcom_PID_FILE=/var/run/$NAME.pid

start() {
        config_load "drcom"
        local enabled
        config_get enabled config enabled

        [ $enabled -eq 0 ] &&{
        stop
        return 0
        }

        [ -f $drcom_PID_FILE ] && {
                echo "Already started: $drcom_PID_FILE exists"
                return 1
        }

        echo -n -e "Starting $DESC... \n"
        $DAEMON > /dev/null 2>/tmp/drcom-monitor.log &
        echo $! > $drcom_PID_FILE
}
drcom_stop() {
        echo "Stopping $DESC... "
        [ -f $drcom_PID_FILE ] && {
                kill -9 `cat $drcom_PID_FILE`
                rm -f $drcom_PID_FILE
        }
}

stop() {
        drcom_stop
}

restart() {
        echo "Restarting $DESC... "
        stop
        sleep 2
        start
}
